﻿using AppService.Dto.System_setting;
using AppService.IService.System_setting;
using Domain.Entity.System_setting;
using Domain.IRepository.System_setting;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;

namespace AppService.Service.System_setting
{
    [Dependency(ServiceLifetime.Scoped)]
    public class DepartService : IDepartService
    {

        public IDepartRepository depart { get; set; }

        public DepartService(IDepartRepository depart)
        {
            this.depart = depart;
        }

        public List<Ment_depart> GetDepart()
        {
            return depart.GetDepart();
        }

        public bool AddDepart(Ment_departDto d)
        {
            Ment_depart ment_Depart = new Ment_depart()
            {
                Depart_id = d.Depart_id,
                Depart_code = d.Depart_code,
                Depart_name = d.Depart_name,
                Depart_pid = d.Depart_pid,
                Depart_remark = d.Depart_remark,
                Depart_status = d.Depart_status,
                Is_del = d.Is_del,
                Comp_id = d.Comp_id,
                Create_by = d.Create_by,
                Create_time = d.Create_time,
                Num_order = d.Num_order,
            };
            return depart.AddDepart(ment_Depart) > 0;
        }

        public bool DelDepart(int id)
        {
            return depart.DelDepart(id) > 0;
        }

        public Ment_depart GetDepartById(int id)
        {
            return depart.GetById(id);
        }

        public Info_company GetByCompId(int id)
        {
            return depart.GetByCompId(id);
        }

        public bool UpdDepart(Ment_departDto d)
        {
            Ment_depart ment_Depart = new Ment_depart()
            {
                Depart_id = d.Depart_id,
                Depart_code = d.Depart_code,
                Depart_name = d.Depart_name,
                Depart_pid = d.Depart_pid,
                Depart_remark = d.Depart_remark,
                Depart_status = d.Depart_status,
                Is_del = d.Is_del,
                Comp_id = d.Comp_id,
                Create_by = d.Create_by,
                Create_time = d.Create_time,
                Num_order = d.Num_order,
            };
            return depart.UpdDepart(ment_Depart) > 0;
        }
    }
}
